package com.itbupt.eat.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author BUPT-Dingchang
 * @Create 2024/4/23 10:56
 * ClassName: MPConfig
 * Description:  MybatisPlus配置类---拦截器
 */

@Configuration
public class MPConfig {

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        // 1. 创建MP的拦截容器
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();

        // 2.往MP拦截器容器中添加分页拦截器
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());

        // 3. 返回拦截器容器
        return interceptor;
    }
}
